package com.situ.team5.kzq.login.controller;

import com.situ.team5.kzq.login.service.LoginService;
import com.situ.team5.pojo.Users;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Map;


@Controller
public class LoginController {
    
    @Autowired
    LoginService loginservice;
     @RequestMapping("login")
    public String login(){

             return "login.html";

    }
    @RequestMapping("index")
    public String index(Users s, Map map,HttpSession session){

        System.out.println(s.getU_name()+""+s.getU_password());
        Users lologin = loginservice.lologin(s);
        if(lologin==null){
            map.put("ts", "对不起，你输入的用户名或密码有误");
            return "login.html";
        }else {
          session.setAttribute("sessuser",lologin );

        return "/page/index.html";
         }
    }
    //退出系统
    @RequestMapping("tcxt")
    public String tcxt(HttpServletRequest request){
        HttpSession session = request.getSession();


        session.removeAttribute("sessuser");



      return "login.html";
    }

    @RequestMapping("left")
    public String left(){
        return "/page/left.html";
    }


    @RequestMapping("main")
    public String main(){
        return "/page/main.html";
    }

    @RequestMapping("top")
    public String top(){
        return "/page/top.html";
    }


}
